app.service('homeService',['$http','$q','utilService',function($http,$q,utilService){
    var _this_=this;

    //查询控制台头部信息
    _this_.queryHomeHeader= function ($scope) {
        var deferred = $q.defer();
        utilService.get({
            url:$scope.app.domain + 'home/sso'
        }).then(function(response){
            deferred.resolve(response.data);
        },function(e){
            console.error(e);
            deferred.reject("连接服务器出错！");
        });

        return deferred.promise;
    };

    //查询订单曲线图
    _this_.queryOrdersInfo= function ($scope) {
        var deferred = $q.defer();
        utilService.get({
            url:$scope.app.domain + 'home/sso/orders',
            params:$scope.homeTableVO
        }).then(function(response){
            deferred.resolve(response.data);
        },function(e){
            console.error(e);
            deferred.reject("连接服务器出错！");
        });

        return deferred.promise;
    };

    //查找店铺
    _this_.queryAllShop= function ($scope) {
        var deferred = $q.defer();
        utilService.get({
            url:$scope.app.domain + 'home/sso/shop'
        }).then(function(response){
            deferred.resolve(response.data);
        },function(e){
            console.error(e);
            deferred.reject("连接服务器出错！");
        });

        return deferred.promise;
    };

    _this_.queryForGoods= function ($scope) {
        var deferred = $q.defer();
        utilService.get({
            url:$scope.app.domain + 'home/sso/goods',
            params:$scope.homeTableVO
        }).then(function(response){
            deferred.resolve(response.data);
        },function(e){
            console.error(e);
            deferred.reject("连接服务器出错！");
        });

        return deferred.promise;
    };


    _this_.queryIncome= function ($scope) {
        delete $scope.homeTableVO.shopId;
        var deferred = $q.defer();
        utilService.get({
            url:$scope.app.domain + 'home/sso/income',
            params:$scope.homeTableVO
        }).then(function(response){
            deferred.resolve(response.data);
        },function(e){
            console.error(e);
            deferred.reject("连接服务器出错！");
        });

        return deferred.promise;
    };



    //查询店铺信息
    _this_.queryChain= function ($scope) {
        var deferred = $q.defer();
        utilService.get({
            url:$scope.app.domain + 'chain/session'
        }).then(function(response){
            deferred.resolve(response.data);
        },function(e){
            console.error(e);
            deferred.reject("连接服务器出错！");
        });

        return deferred.promise;
    }

}]);